package com.zking.ssm.DYM.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zking.ssm.DYM.mapper.HotelRoomNumMapper;
import com.zking.ssm.DYM.model.HotelRoomNum;
import com.zking.ssm.DYM.service.IHotelRoomNumService;
import com.zking.ssm.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description
 * @Author XXXXX
 * @Date 2021/01/20 9:56
 */
@Service
public class HotelRoomNumServiceImpl implements IHotelRoomNumService {
    @Autowired
    private HotelRoomNumMapper hotelRoomNumMapper;

    public HotelRoomNumServiceImpl() {
        super();
    }

    public HotelRoomNumMapper getHotelRoomNumMapper() {
        return hotelRoomNumMapper;
    }

    public void setHotelRoomNumMapper(HotelRoomNumMapper hotelRoomNumMapper) {
        this.hotelRoomNumMapper = hotelRoomNumMapper;
    }


    @Override
    public HotelRoomNum selectByPrimaryKey(Long id) {
        return hotelRoomNumMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(HotelRoomNum record) {
        return hotelRoomNumMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<HotelRoomNum> list(HotelRoomNum hotelRoomNum, PageBean pageBean) {
        if (null != pageBean && pageBean.isPagination()) {
            PageHelper.startPage(pageBean.getPage(), pageBean.getRows());
        }
        List<HotelRoomNum> hotelRoomNumList = hotelRoomNumMapper.list(hotelRoomNum);
        System.out.println(hotelRoomNumList.getClass().getName());
        if(null != pageBean && pageBean.isPagination()){
            PageInfo pageInfo = new PageInfo(hotelRoomNumList);
            pageBean.setTotal(pageInfo.getTotal()+"");
        }
        return hotelRoomNumMapper.list(hotelRoomNum);
    }
}
